// 一个webpack的api,通过执行require.context函数获取一个特定的上下文,主要用来实现自动化导入模块
// const files = require.context('.', false, /\.js$/);
// let configRouters = [];

// files.keys().forEach((key) => {
//     if (key === './index.js') return;
//     configRouters = configRouters.concat(files(key).default); // 读取文件中的 default 模块
// });

// console.log(configRouters);
const configRouters = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import(/* webpackChunkName: "home" */ '@/views/Home'),
        redirect: '/guide',
        children: [
            {
                // 引导页
                path: '/guide',
                name: 'Guide',
                meta: {
                    name: 'guide',
                    title: '欢迎使用',
                    comp: 'guide'
                },
                component: () => import('@/views/Guide/guide')
            },
            {
                // 首页
                path: '/index',
                name: 'Index',
                meta: {
                    name: 'index',
                    title: '首页',
                    comp: 'Index'
                },
                component: () => import('@/views/index/Index')
            },
            {
                path: '/search',
                name: 'Search',
                component: () => import('@/views/OneClickSearch/GoSearch.vue')
            },
            {
                // 人员管理
                path: '/person_manage',
                name: 'PersonManage',
                meta: {
                    name: 'PersonManage',
                    title: '人员管理',
                    comp: 'manage'
                },
                component: () => import('@/views/PersonManage/manage')
            },
            {
                path: '/case_manage',
                name: 'CaseManage',
                meta: {
                    name: 'CaseManage',
                    title: '物品管理',
                    comp: 'CaseManage'
                },
                component: () => import('@/views/CaseManage/manage')
            },
            {
                path: '/person_involved',
                name: 'involved',
                meta: {
                    name: 'involved',
                    title: '物件研判',
                    comp: 'involved'
                },
                component: () => import('@/views/CaseManage/involved')
            },
            {
                path: '/search',
                name: '一键搜',
                meta: {
                    name: '一键搜',
                    title: '一键搜',
                    comp: 'Search'
                },
                component: () => import('@/views/OneClickSearch/GoSearch')
            }
        ]
    }
];

export default configRouters; // 抛出一个 Vue-router 期待的结构的数组
